Bug 995595

Summary: defensive-coding-guide: Incorrect advice on array allocation
Product: [Fedora] Fedora Documentation Reporter: Gé Baylard <Geodebay>
Component: defensive-coding-guideAssignee: Florian Weimer <fweimer>
Status: CLOSED EOL QA Contact: Fedora Docs QA <docs-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: develCC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-07 15:30:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1000995    

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.