Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #153588
| From | John Forkosh <forkosh@panix.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide |
| Date | 2020-08-13 06:15 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <rh2lpf$5v3$1@reader1.panix.com> (permalink) |
| References | <rh1du1$q82$1@dont-email.me> <877du33by4.fsf@nosuchdomain.example.com> <alpine.BSF.2.22.395.2008121503080.21003@slashem.me> <rh2475$r12$1@reader1.panix.com> <87r1sb1fu5.fsf@nosuchdomain.example.com> |
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> John Forkosh <forkosh@panix.com> writes:
>> Elijah Stone <elronnd@elronnd.net> wrote:
>>> On Wed, 12 Aug 2020, Keith Thompson wrote:
>>>
>>>> Casting the result of malloc is also disturbing.
>>> Agreed.
>>
>> What's wrong with that? (Or are you suggesting that calloc()
>> should be used instead?)
>
> No, I'm not suggesting using calloc().
>
> This is explained in section 7 of the comp.lang.c FAQ.
> http://www.c-faq.com/
You specifically mean http://www.c-faq.com/malloc/mallocnocast.html
And that's way, way (,way...) too -pedantic. Sounds like it was
written by some pompous, arrogant bully. I especially like the part
where it says...
"the compiler is likely to assume that you know what you're doing"
Heaven forbid!!! You know what you're doing???
Never in a million years!!!
And I also like your sig where it says...
"Working, but not speaking, for ..."
Yeah! Now you've got it! >>That's<< what the C compiler should be
doing. It's working for me, and should do what I say, how I say it.
A warning/suggestion here and there is fine, but no hard-and-fast
pronouncements about style or anything else. And if I screw up,
then that's on me. But in no way, shape or form, to follow the
analogy suggested by the github example, should the tail be
wagging the dog!!! Like you do (the faq does) right here...
> The article
> https://thephd.github.io/
> your-c-compiler-and-standard-library-will-not-help-you
> has:
> struct Meow* p_cat = (struct Meow*)malloc(sizeof(struct Meow));
>
> This would be better written as:
> struct Meow *p_cat = malloc(sizeof *p_cat);
>
> The cast is unnecessary, since there's an implicit conversion from
> void* to struct Meow*. The type name "struct Meow" is written
> 3 times. An editing error could easily result in an inconsistency,
> allocating the wrong size and/or using a pointer of the wrong type.
> Using the size of *p_cat avoids having to name the type and allows
> for changing the type without breaking the code.
The remark "An editing error could easily result in" a program error
just sound like a half-elbowed excuse to shove the faq's pompous and
bullying style down someone else's throat. Gee, an editing error
can result in an error??? Really???
I personally do bind the * to the *p_, but would also write it as,
typedef struct Meow meow
meow *p_cat = (meow *)malloc(sizeof(meow));
which is just how I personally like to read and write it.
And if that faq doesn't like it, then it can just go rewrite itself:)
--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
"Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Lynn McGuire <lynnmcguire5@gmail.com> - 2020-08-12 13:54 -0500
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-12 12:23 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Elijah Stone <elronnd@elronnd.net> - 2020-08-12 15:05 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-12 19:15 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Philipp Klaus Krause <pkk@spth.de> - 2020-08-13 10:36 +0200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Poprocks <please@replytogroup.com> - 2020-08-13 14:23 +0000
What do when -Werror gets in your way (Was: "Why the C Language Will Never Stop You from Making Mistakes") by JeanHeyd Meneide gazelle@shell.xmission.com (Kenny McCormack) - 2020-08-13 14:49 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Elijah Stone <elronnd@elronnd.net> - 2020-08-13 23:25 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide John Forkosh <forkosh@panix.com> - 2020-08-13 01:15 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-12 18:42 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide John Forkosh <forkosh@panix.com> - 2020-08-13 06:15 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-12 23:23 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide John Forkosh <forkosh@panix.com> - 2020-08-13 06:44 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Poprocks <please@replytogroup.com> - 2020-08-15 22:51 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-15 19:41 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-08-16 02:02 +0100
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide John Forkosh <forkosh@panix.com> - 2020-08-16 05:47 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-08-16 12:03 +0100
Kinda by definition... (Was: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide) gazelle@shell.xmission.com (Kenny McCormack) - 2020-08-16 11:49 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-16 05:33 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide John Forkosh <forkosh@panix.com> - 2020-08-17 06:27 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-16 09:12 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-13 07:38 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-13 09:33 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-14 10:50 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-14 12:39 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-14 16:53 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-14 19:49 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-08-15 02:31 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-15 16:10 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-16 09:25 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-16 10:50 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-16 15:40 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Damon <Richard@Damon-Family.org> - 2020-08-16 19:39 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-16 21:12 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Harnden <richard.nospam@gmail.com> - 2020-08-18 08:47 +0100
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-18 08:26 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide gazelle@shell.xmission.com (Kenny McCormack) - 2020-08-13 12:48 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide John Bode <jfbode1029@gmail.com> - 2020-08-13 09:46 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-08-13 06:14 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Anton Shepelev <anton.txt@gmail.com> - 2020-08-13 01:19 +0300
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-12 16:18 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Scott Newman <scott69@gmail.com> - 2020-08-13 09:25 +0200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-13 00:41 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Scott Newman <scott69@gmail.com> - 2020-08-13 12:53 +0200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Richard Harnden <richard.nospam@gmail.com> - 2020-08-13 12:52 +0100
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide David Brown <david.brown@hesbynett.no> - 2020-08-13 15:17 +0200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-13 10:38 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Scott Newman <scott69@gmail.com> - 2020-08-13 19:44 +0200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Bart <bc@freeuk.com> - 2020-08-13 19:10 +0100
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-08-13 11:42 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide scott@slp53.sl.home (Scott Lurndal) - 2020-08-14 05:56 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Bonita Montero <Bonita.Montero@gmail.com> - 2020-08-14 09:14 +0200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-08-14 08:45 -0400
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide gazelle@shell.xmission.com (Kenny McCormack) - 2020-08-14 16:51 +0000
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Ian Collins <ian-news@hotmail.com> - 2020-08-15 09:11 +1200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-08-24 16:58 -0700
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Philipp Klaus Krause <pkk@spth.de> - 2020-08-13 10:32 +0200
Re: "Why the C Language Will Never Stop You from Making Mistakes" by JeanHeyd Meneide Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-08-23 07:04 -0700
csiph-web