| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 5 |
<title>Coding Style: p11-kit</title> |
| 6 |
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"> |
| 7 |
<link rel="home" href="index.html" title="p11-kit"> |
| 8 |
<link rel="up" href="devel.html" title="Building, Packaging, and Contributing to p11-kit"> |
| 9 |
<link rel="prev" href="devel-building.html" title="Compiling p11-kit from Source"> |
| 10 |
<link rel="next" href="devel-testing.html" title="Testing and Code Coverage"> |
| 11 |
<meta name="generator" content="GTK-Doc V1.34.0 (XML mode)"> |
| 12 |
<link rel="stylesheet" href="style.css" type="text/css"> |
| 13 |
</head> |
| 14 |
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| 15 |
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> |
| 16 |
<td width="100%" align="left" class="shortcuts"></td> |
| 17 |
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> |
| 18 |
<td><a accesskey="u" href="devel.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> |
| 19 |
<td><a accesskey="p" href="devel-building.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> |
| 20 |
<td><a accesskey="n" href="devel-testing.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> |
| 21 |
</tr></table> |
| 22 |
<div class="section"> |
| 23 |
<div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| 24 |
<a name="devel-building-style"></a>Coding Style</h2></div></div></div> |
| 25 |
<p>We use a code style similar to the linux kernel. Use tabs |
| 26 |
to indent and spaces to align/wrap beyond the indentation level.</p> |
| 27 |
<p>We don't try to guarantee completely robust and problem free |
| 28 |
behavior in cases where the caller or system isn't behaving. We |
| 29 |
consider these to be outside of our control:</p> |
| 30 |
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| 31 |
<li class="listitem"><p>Broken input from callers. We use preconditions |
| 32 |
to check input and immediately return. We don't try to provide |
| 33 |
error codes for all the various ways callers can screw |
| 34 |
around.</p></li> |
| 35 |
<li class="listitem"> |
| 36 |
<p>Out of memory. It is pretty much impossible to handle out |
| 37 |
of memory errors correctly. Handling them alongside other errors |
| 38 |
is naive and broken. We don't try to guarantee library state |
| 39 |
(such as locks or memory leaks) when memory allocation fails.</p> |
| 40 |
<p>We do check the results from all memory allocations, but |
| 41 |
treat them as unexpected conditions. As a nod to the behavior |
| 42 |
of callers of this library, we don't abort on memory allocation |
| 43 |
failures. We use preconditions with somewhat sane results.</p> |
| 44 |
<p>Exception: when reading files or allocating potentially |
| 45 |
unbounded amounts of memory, we should respond robustly to memory |
| 46 |
allocation failures.</p> |
| 47 |
</li> |
| 48 |
</ul></div> |
| 49 |
<p>These unexpected conditions indicate a bug either in p11-kit or |
| 50 |
in the system. All bets are off once this occurs.</p> |
| 51 |
<p>Use the <code class="literal">return_val_xxx()</code> precondition macros to |
| 52 |
check for unexpected conditions.</p> |
| 53 |
</div> |
| 54 |
<div class="footer"> |
| 55 |
<hr>Generated by GTK-Doc V1.34.0</div> |
| 56 |
</body> |
| 57 |
</html> |