Bug 995595 - defensive-coding-guide: Incorrect advice on array allocation
Summary: defensive-coding-guide: Incorrect advice on array allocation
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora Documentation
Classification: Retired
Component: defensive-coding-guide
Version: devel
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Florian Weimer
QA Contact: Fedora Docs QA
URL:
Whiteboard:
Depends On:
Blocks: 1000995
TreeView+ depends on / blocked
 
Reported: 2013-08-09 19:41 UTC by Gé Baylard
Modified: 2019-11-07 15:30 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-07 15:30:15 UTC
Embargoed:


Attachments (Terms of Use)

Description Gé Baylard 2013-08-09 19:41:18 UTC
Description of problem:
In Allocators.xml, line 135 to 138, you write:
"     ....  For instance,
      to allocate an array of <literal>n</literal> elements of type
      <literal>T</literal>, check that the requested size is not
      greater than <literal>n / sizeof(T)</literal>."

It is not rather?
"   ....  For instance,
      to allocate an array of <literal>n</literal> elements of type
      <literal>T</literal>, check that the requested size is not
      smaller than <literal>n * sizeof(T)</literal>."


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Florian Weimer 2013-08-09 20:08:08 UTC
(In reply to Gé Baylard from comment #0)
> Description of problem:
> In Allocators.xml, line 135 to 138, you write:
> "     ....  For instance,
>       to allocate an array of <literal>n</literal> elements of type
>       <literal>T</literal>, check that the requested size is not
>       greater than <literal>n / sizeof(T)</literal>."
> 
> It is not rather?
> "   ....  For instance,
>       to allocate an array of <literal>n</literal> elements of type
>       <literal>T</literal>, check that the requested size is not
>       smaller than <literal>n * sizeof(T)</literal>."

Right, this is buggy, the expresion should be <literal>(~(size_t)0) / sizeof(T)</literal>.  Thanks for spotting this.

Comment 2 Florian Weimer 2013-08-26 09:46:20 UTC
Fixed in 876a1bcbd0b2687867aded985d142df5030988ae.  Thanks again.

Comment 3 Eric Christensen 2014-06-27 13:59:35 UTC
What's the status of this?  Did this make it into the guide?

Comment 4 Florian Weimer 2014-06-27 14:17:37 UTC
See comment #2.  The Docbook sources have been updated, but we have not been able to publish an updated HTML version.  Before we can do that, we need to update the revision log.

Comment 5 Petr Bokoc 2019-11-07 15:30:15 UTC
I'm closing this bug as part of a Bugzilla cleanup effort. The most likely reason is that the bug has been opened either against a component we no longer publish, or against Release Notes for an EOL release.


Note You need to log in before you can comment on or make changes to this bug.