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