1 Submitting patches or diff's to the FreeRADIUS project
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
9 SECTION 1 - CREATING AND SENDING YOUR CHANGE
13 Use "diff -u" or "diff -urN" to create patches.
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.
21 To create a patch for a single file, it is often sufficient to do:
23 SRCTREE=/home/user/src/freeradiusd/
24 MYFILE=src/modules/rlm_foo/foo.c
27 cp $MYFILE $MYFILE.orig
28 vi $MYFILE # make your change
29 diff -u $MYFILE.orig $MYFILE > /tmp/patch
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:
35 MYSRC=/home/user/src/freeradiusd-feature/
37 gunzip freeradiusd-version.tar.gz
38 tar xvf freeradiusd-version.tar
39 diff -urN freeradiusd-version $MYSRC > ~/feature-version.patch
41 2. Describe your changes.
43 Describe the technical detail of the change(s) your patch includes.
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."
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.
52 3. Separate your changes.
54 Separate each logical change into its own patch.
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.
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.
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.
68 4. Select e-mail destination.
70 If you are on the developers mailing list, send the patch there.
71 freeradius-devel@lists.freeradius.org
73 Otherwise, send the patch to 'patches@freeradius.org'
75 5. No MIME, no links, no compression, no attachments. Just plain text.
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.
82 For this reason, all patches should be submitting e-mail
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
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.
98 When sending patches, always follow step #5.
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.
105 7. Name the version of the server.
107 It is important to note, either in the subject line or in the
108 patch description, the server version to which this patch
111 8. Don't get discouraged. Re-submit.
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.
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
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
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
131 When in doubt, re-submit.
133 SECTION 2 - HINTS, TIPS, AND TRICKS
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.
139 1. Read the Documentation and follow the CodingStyle
141 The FreeRADIUS server has a common coding style. Use real tabs
142 to indent. There is whitespace in variable assignments.
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
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"
158 Simple example, of poor code:
160 #ifdef CONFIG_MY_FUNKINESS
168 #ifndef CONFIG_MY_FUNKINESS
169 static inline void init_my_stuff(char *foo) {}
178 3. 'static inline' is better than a macro
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.
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].
189 'static inline' is preferred over 'static __inline__', 'extern
190 inline', and 'extern __inline__'.
192 4. Don't over-design.
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"
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
202 See the 'coding-methods.txt' document in this directory for
203 further description of coding methods.