public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Prevent malloc with size 0
Date: Fri, 22 Oct 2010 13:06:14 -0400	[thread overview]
Message-ID: <201010221306.15686.vapier@gentoo.org> (raw)
In-Reply-To: <OFE56C9929.AC33AFD9-ONC12577C4.005AA30E-C12577C4.005B9045@transmode.se>

On Friday, October 22, 2010 12:40:07 Joakim Tjernlund wrote:
> Mike Frysinger wrote on 2010/10/22 17:18:05:
> > On Friday, October 22, 2010 04:34:52 Joakim Tjernlund wrote:
> > > Don't you want to know if the app screwed up or if the system is out
> > > of memory?
> > > 
> > > The only upside to malloc(0) == NULL I can see is an extra check
> > > for apps for which size == 0 is an error to the app too(something the
> > > app should have checked itself long before calling malloc).
> > 
> > if an app is doing malloc(0), it is broken.  i'm really not worried at
> > all
> 
> In your opinion, not mine and not POSIX either. I outlined uses for
> malloc(0) earlier.

i havent seen any realistic usage examples.  the only ones you quoted could 
easily be solved in a different way assuming they were even affected by 
malloc(0).

> > about detecting OOM state.  my real world experience thus far has shown
> > no actual problems with this behavior.  so unless you have some actual
> > examples where this behavior "harms" u-boot, i say we merge the OP's
> > patch.
> 
> Since you think an app is broken if it does malloc(0), it should not matter
> what malloc(0) returns to you. You only gain an extra error check for the
> broken app at the expense of ease of use and sane error checking in
> general.

more like you notice that the code is broken right away.  the few times i have 
seen a malloc(0), it was do to errors elsewhere in the code and once those 
were fixed, malloc() wasnt called with a size 0.

> I prefer not to make it easier for broken apps when it hurts elsewhere.

funny, i can use the same logic to ban malloc(0).  it makes you notice & fix 
errors without penalties.

> Ah, IT changed some settings globally. I changed it back. I hope this reply
> is better.

yes, this is much better.  thanks !
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101022/0b9082f7/attachment.pgp 

  reply	other threads:[~2010-10-22 17:06 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21  9:24 [U-Boot] [PATCH] Prevent malloc with size 0 Kostaras Nikolaos
2010-10-21 11:25 ` Joakim Tjernlund
2010-10-21 11:32   ` Wolfgang Denk
2010-10-21 11:45     ` Joakim Tjernlund
2010-10-21 11:51       ` Wolfgang Denk
2010-10-21 11:56         ` Joakim Tjernlund
2010-10-21 12:02           ` Wolfgang Denk
2010-10-21 12:54             ` Joakim Tjernlund
2010-10-21 19:51       ` Mike Frysinger
2010-10-21 21:10         ` Graeme Russ
2010-10-21 21:27           ` Mike Frysinger
2012-03-31 19:59             ` Marek Vasut
2012-04-01 12:25               ` Joakim Tjernlund
2012-04-01 14:01                 ` Marek Vasut
2012-04-01 14:15                   ` Joakim Tjernlund
2012-04-01 14:21                     ` Marek Vasut
2012-04-01 22:40                       ` Graeme Russ
2012-04-01 23:45                         ` Marek Vasut
2012-04-01 23:52                           ` Graeme Russ
2012-04-02  0:13                             ` Marek Vasut
2012-04-02  0:25                               ` Graeme Russ
2012-04-02  1:04                                 ` Marek Vasut
2012-04-02  1:40                                   ` Graeme Russ
2012-04-02  2:51                                     ` Marek Vasut
2012-04-02  3:05                                       ` Graeme Russ
2012-04-02  6:39                                         ` Joakim Tjernlund
2012-04-02  3:12                                 ` Mike Frysinger
2012-04-02  3:16                                   ` Graeme Russ
2012-04-02  3:36                                   ` Marek Vasut
2012-04-02  3:43                                     ` Graeme Russ
2012-04-02  4:23                                       ` Marek Vasut
2012-04-02  4:27                                         ` Graeme Russ
2012-04-02  6:55                                       ` Joakim Tjernlund
2012-04-02  7:17                                         ` Graeme Russ
2012-04-02  7:40                                           ` Joakim Tjernlund
2012-04-02 14:05                                             ` Marek Vasut
2012-04-02 14:26                                               ` Joakim Tjernlund
2012-04-02 14:42                                                 ` Marek Vasut
2012-04-02 15:08                                                   ` Joakim Tjernlund
2012-04-02 15:23                                                     ` Marek Vasut
2012-04-02 16:00                                                       ` Joakim Tjernlund
2012-04-02 16:39                                                         ` Marek Vasut
2012-04-02 17:22                                                           ` Joakim Tjernlund
2012-04-02 18:00                                                             ` Marek Vasut
2012-04-02 18:40                                                               ` Joakim Tjernlund
2012-04-02 19:14                                                                 ` Mike Frysinger
2012-04-02 21:02                                                                   ` Joakim Tjernlund
2012-04-02 19:23                                                                 ` Marek Vasut
2012-04-02 20:28                                             ` Graeme Russ
2012-04-02 20:56                                               ` Joakim Tjernlund
2012-04-02 20:59                                                 ` Graeme Russ
2012-04-02 21:14                                                   ` Joakim Tjernlund
2012-04-02 23:35                                                     ` Graeme Russ
2012-04-03 10:35                                                       ` Graeme Russ
2012-10-16  6:31                                                         ` Marek Vasut
2012-10-16  9:22                                                           ` Joakim Tjernlund
2012-10-16 10:43                                                             ` Marek Vasut
2012-10-16 11:46                                                               ` Joakim Tjernlund
2012-10-16 10:43                                                           ` Wolfgang Denk
2012-10-16 22:41                                                             ` Graeme Russ
2012-04-02  3:10                         ` Mike Frysinger
2012-04-02  3:36                           ` Marek Vasut
2010-10-22  6:10         ` Joakim Tjernlund
2010-10-22  7:18           ` Reinhard Meyer
2010-10-22  7:47             ` Joakim Tjernlund
2010-10-22  7:20           ` Mike Frysinger
2010-10-22  7:37             ` Joakim Tjernlund
2010-10-22  7:55               ` Mike Frysinger
2010-10-22  8:34                 ` Joakim Tjernlund
2010-10-22 15:18                   ` Mike Frysinger
2010-10-22 16:40                     ` Joakim Tjernlund
2010-10-22 17:06                       ` Mike Frysinger [this message]
2010-10-23  9:14                         ` Joakim Tjernlund
2010-10-22 17:36                 ` Scott Wood
2010-10-23  9:23                   ` Joakim Tjernlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201010221306.15686.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox