Fixes
[freeradius.git] / doc / DIFFS
1         Submitting patches or diff's to the FreeRADIUS project
2
3 For a person or company wishing to submit a change to the
4 FreeRADIUS project, the process can sometimes be daunting if you're
5 not familiar with "the system." This text is a collection of
6 suggestions which can greatly increase the chances of your change
7 being accepted.
8
9 SECTION 1 - CREATING AND SENDING YOUR CHANGE 
10
11    1. "diff -u" 
12
13       Use "diff -u" or "diff -urN" to create patches. 
14
15       All changes to the source occur in the form of patches, as
16       generated by diff(1).  When creating your patch, make sure to
17       create it in "unified diff" format, as supplied by the '-u'
18       argument to diff(1). Patches should be based in the root source
19       directory, not in any lower subdirectory.
20
21       To create a patch for a single file, it is often sufficient to do: 
22
23            SRCTREE=/home/user/src/freeradiusd/
24            MYFILE=src/modules/rlm_foo/foo.c
25             
26            cd $SRCTREE
27            cp $MYFILE $MYFILE.orig
28            vi $MYFILE # make your change
29            diff -u $MYFILE.orig $MYFILE > /tmp/patch 
30
31       To create a patch for multiple files, you should unpack a
32       "vanilla", or unmodified source tree, and generate a diff
33       against your own source tree. For example:
34
35            MYSRC=/home/user/src/freeradiusd-feature/
36             
37            gunzip freeradiusd-version.tar.gz
38            tar xvf freeradiusd-version.tar
39            diff -urN freeradiusd-version $MYSRC > ~/feature-version.patch
40
41    2. Describe your changes. 
42
43       Describe the technical detail of the change(s) your patch includes. 
44
45       Be as specific as possible. The WORST descriptions possible
46       include things like "update file X", "bug fix for file X",
47       or "this patch includes updates for subsystem X. Please apply."
48
49       If your description starts to get long, that's a sign that you
50       probably need to split up your patch. See #3, next.
51
52    3. Separate your changes. 
53
54       Separate each logical change into its own patch.
55
56       For example, if your changes include both bug fixes and
57       performance enhancements for a single module, separate those
58       changes into two or more patches.
59
60       On the other hand, if you make a single change to numerous
61       files, group those changes into a single patch. Thus a single
62       LOGICAL change is contained within a single patch.
63
64       If one patch depends on another patch in order for a change to
65       be complete, that is OK. Simply note "this patch depends on
66       patch X" in your patch description.
67
68    4. Select e-mail destination. 
69
70       If you are on the developers mailing list, send the patch there.
71       freeradius-devel@lists.freeradius.org
72
73       Otherwise, send the patch to 'patches@freeradius.org'
74
75    5. No MIME, no links, no compression, no attachments. Just plain text. 
76
77       The developers need to be able to read and comment on the
78       changes you are submitting. It is important for a developer to
79       be able to "quote" your changes, using standard e-mail tools, so
80       that they may comment on specific portions of your code.
81
82       For this reason, all patches should be submitting e-mail
83       "inline".
84
85       Do not attach the patch as a MIME attachment, compressed or
86       not. Many popular e-mail applications will not always transmit a
87       MIME attachment as plain text, making it impossible to comment
88       on your code. A MIME attachment also takes a bit more time to
89       process, decreasing the likelihood of your MIME-attached change
90       being accepted.
91
92       Compressed patches are generally rejected outright.  If the
93       developer has to do additional work to read your patch, the odds
94       are that it will be ignored completely.
95
96    6. E-mail size. 
97
98       When sending patches, always follow step #5. 
99
100       Large changes are not appropriate for mailing lists, and some
101       maintainers. If your patch, exceeds 40Kb in size, it is
102       preferred that you store your patch on an Internet-accessible
103       server, and provide instead a URL (link) pointing to your patch.
104
105    7. Name the version of the server.
106
107       It is important to note, either in the subject line or in the
108       patch description, the server version to which this patch
109       applies.
110
111    8. Don't get discouraged. Re-submit. 
112
113       After you have submitted your change, be patient and wait. If
114       the patch is approved and applied, it will appear in the next
115       version of the server.
116
117       However, if your change doesn't appear in the next version of
118       the server, there could be any number of reasons. It's YOUR job
119       to narrow down those reasons, correct what was wrong, and submit
120       your updated change.
121
122       It is quite common a patch to be "dropped" without
123       comment. That's the nature of the system. If your patch is
124       dropped, it could be due to
125
126            A style issue (see section 2, below),
127            An e-mail formatting issue (see section item 5, above)
128            A technical problem with your change 
129            Your patch got lost among other patches
130
131       When in doubt, re-submit.
132
133 SECTION 2 - HINTS, TIPS, AND TRICKS 
134
135 This section lists many of the common "rules" associated with code
136 submitted to the project. There are always exceptions... but you must
137 have a really good reason for doing so.
138
139    1. Read the Documentation and follow the CodingStyle 
140
141       The FreeRADIUS server has a common coding style.  Use real tabs
142           to indent.  There is whitespace in variable assignments.
143       (i = 1, NOT i=1).
144
145       When in doubt, format your code to look the same as code already
146       in the server.  If your code deviates too much from the current
147       style, it is likely to be rejected without further review, and
148       without comment.
149
150    2. #ifdefs are ugly 
151
152       Code cluttered with ifdefs is difficult to read and
153       maintain. Don't do it. Instead, put your ifdefs in a header, and
154       conditionally define 'static inline' functions, or macros, which
155       are used in the code. Let the compiler optimize away the "no-op"
156       case.
157
158       Simple example, of poor code: 
159
160            #ifdef CONFIG_MY_FUNKINESS 
161                  init_my_stuff(foo);
162            #endif 
163
164       Cleaned-up example: 
165
166       (in header) 
167
168            #ifndef CONFIG_MY_FUNKINESS
169            static inline void init_my_stuff(char *foo) {}
170            #endif 
171
172       (in the code itself) 
173
174            ...
175            init_my_stuff(dev); 
176            ...
177
178    3. 'static inline' is better than a macro 
179
180       Static inline functions are greatly preferred over macros. They
181       provide type safety, have no length limitations, no formatting
182       limitations, and under gcc they are as cheap as macros.
183
184       Macros should only be used for cases where a static inline is
185       clearly suboptimal [there a few, isolated cases of this in fast
186       paths], or where it is impossible to use a static inline
187       function [such as string-izing].
188
189       'static inline' is preferred over 'static __inline__', 'extern
190       inline', and 'extern __inline__'.
191
192    4. Don't over-design. 
193
194       Don't try to anticipate nebulous future cases which may or may
195       not be useful: "Make it as simple as you can, and no simpler"
196
197       Split up functionality as much as possible.  If your code needs
198       to do two unrelated things, write two functions.  Mashing two
199       kinds of work into one function makes the server difficult to
200       debug and maintain.
201
202       See the 'coding-methods.txt' document in this directory for
203       further description of coding methods.