Bug 995595 - defensive-coding-guide: Incorrect advice on array allocation
defensive-coding-guide: Incorrect advice on array allocation
Status: MODIFIED
Product: Fedora Documentation
Classification: Fedora
Component: defensive-coding-guide (Show other bugs)
devel
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Florian Weimer
Fedora Docs QA
:
Depends On:
Blocks: 1000995
  Show dependency treegraph
 
Reported: 2013-08-09 15:41 EDT by Gé Baylard
Modified: 2014-10-21 12:27 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Gé Baylard 2013-08-09 15:41:18 EDT
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 16:08:08 EDT
(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 05:46:20 EDT
Fixed in 876a1bcbd0b2687867aded985d142df5030988ae.  Thanks again.
Comment 3 Eric Christensen 2014-06-27 09:59:35 EDT
What's the status of this?  Did this make it into the guide?
Comment 4 Florian Weimer 2014-06-27 10:17:37 EDT
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.

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