Commit f10efe39f308066ad1e932e6b16b8133880aee6e

Authored by Jay Berkenbilt
1 parent 0152f254

Tweak README-maintainer about unique_ptr

Also remove trailing whitespace
Showing 1 changed file with 41 additions and 32 deletions
README-maintainer.md
... ... @@ -77,7 +77,7 @@ configurations.
77 77 * The version number on the main branch is whatever the version would
78 78 be if the top of the branch were released. If the most recent
79 79 release is version a.b.c, then
80   -
  80 +
81 81 * If there are any ABI-breaking changes since the last release,
82 82 main's version is a+1.0.0
83 83 * Else if there is any new public API, main's version is a.b+1.0
... ... @@ -116,9 +116,9 @@ Building docs from pull requests is also enabled.
116 116  
117 117 * To test locally, see https://github.com/google/oss-fuzz/tree/master/docs/,
118 118 especially new_project_guide.md. Summary:
119   -
  119 +
120 120 Clone the oss-fuzz project. From the root directory of the repository:
121   -
  121 +
122 122 ```
123 123 python3 infra/helper.py build_image --pull qpdf
124 124 python3 infra/helper.py build_fuzzers [ --sanitizer memory|undefined|address ] qpdf [path-to-qpdf-source]
... ... @@ -126,18 +126,18 @@ Building docs from pull requests is also enabled.
126 126 python3 infra/helper.py build_fuzzers --sanitizer coverage qpdf
127 127 python3 infra/helper.py coverage qpdf
128 128 ```
129   -
  129 +
130 130 To reproduce a test case, build with the correct sanitizer, then run
131   -
  131 +
132 132 python3 infra/helper.py reproduce qpdf <specific-fuzzer> testcase
133   -
  133 +
134 134 where fuzzer is the fuzzer used in the crash.
135   -
  135 +
136 136 The fuzzer is in build/out/qpdf. It can be run with a directory as
137 137 an argument to run against files in a directory. You can use
138   -
  138 +
139 139 qpdf_fuzzer -merge=1 cur new >& /dev/null&
140   -
  140 +
141 141 to add any files from new into cur if they increase coverage. You
142 142 need to do this with the coverage build (the one with
143 143 --sanitizer coverage)
... ... @@ -160,18 +160,18 @@ Building docs from pull requests is also enabled.
160 160 * Use std::to_string instead of QUtil::int_to_string et al
161 161  
162 162 * Use of assert:
163   -
  163 +
164 164 * Test code: #include <qpdf/assert_test.h> first.
165 165 * Debug code: #include <qpdf/assert_debug.h> first and use
166 166 qpdf_assert_debug instead of assert.
167   -
  167 +
168 168 These rules are enforced by the check-assert test. This practices
169 169 serves to
170   -
  170 +
171 171 * remind us that assert in release code disappears and so should only
172 172 be used for debugging; when doing so use a Debug build
173 173 configuration
174   -
  174 +
175 175 * protect us from using assert in test code without explicitly
176 176 removing the NDEBUG definition, since that would cause the assert
177 177 not to actually be testing anything in non-Debug build
... ... @@ -220,7 +220,7 @@ Building docs from pull requests is also enabled.
220 220 dynamic_cast with those, but doing it anyway may help with some
221 221 strange cases for mingw or with some code generators that may
222 222 systematically do this for other reasons.
223   -
  223 +
224 224 IMPORTANT NOTE ABOUT QPDF_DLL_CLASS: On mingw, the vtable for a
225 225 class with some virtual methods and no pure virtual methods seems
226 226 often (always?) not to be generated if the destructor is inline or
... ... @@ -229,7 +229,7 @@ Building docs from pull requests is also enabled.
229 229 methods, you must declare the destructor in the header without
230 230 `= default` and provide a non-inline implementation in the source
231 231 file. Add this comment to the implementation:
232   -
  232 +
233 233 ```cpp
234 234 // Must be explicit and not inline -- see QPDF_DLL_CLASS in
235 235 // README-maintainer
... ... @@ -255,6 +255,16 @@ Building docs from pull requests is also enabled.
255 255 class initialized to nullptr to give the flexibility to add data members
256 256 without breaking the ABI.
257 257  
  258 + Note that, as of qpdf 11, many public classes use `std::shared_ptr`
  259 + instead. Changing this to `std::unique_ptr` is ABI-breaking. If the
  260 + class doesn't allow copying, we can switch it to std::unique_ptr and
  261 + let that be the thing that prevents copying. If the intention is to
  262 + allow the object to be copied by value and treated as if it were
  263 + copied by reference, then `std::shared_ptr<Members>` should be used.
  264 + The `JSON` class is an example of this. As a rule, we should avoid
  265 + this design pattern. It's better to make things non-copiable and to
  266 + require explicit use of shared pointers, so going forward,
  267 + `std::unique_ptr` should be preferred.
258 268  
259 269 * Traversal of objects is expensive. It's worth adding some complexity
260 270 to avoid needless traversals of objects.
... ... @@ -323,13 +333,13 @@ When done, the following should happen:
323 333  
324 334 * Each year, update copyright notices. This will find all relevant
325 335 places (assuming current copyright is from last year):
326   -
  336 +
327 337 git --no-pager grep -i -n -P "copyright.*$(expr $(date +%Y) - 1).*berkenbilt"
328   -
  338 +
329 339 Also update the copyright in these places:
330 340 * debian package -- search for copyright.*berkenbilt in debian/copyright
331 341 * qtest-driver, TestDriver.pm in qtest source
332   -
  342 +
333 343 Copyright last updated: 2023.
334 344  
335 345 * Take a look at "External Libraries" in TODO to see if we need to
... ... @@ -351,24 +361,24 @@ When done, the following should happen:
351 361 * Check work `qpdf` project for private issues
352 362  
353 363 * Make sure the code is formatted.
354   -
  364 +
355 365 ./format-code
356 366  
357 367 * Run a spelling checker over the source code to catch errors in
358 368 variable names, strings, and comments.
359   -
  369 +
360 370 ./spell-check
361   -
  371 +
362 372 This uses cspell. Install with `npm install -g cspell`. The output
363 373 of cspell is suitable for use with `M-x grep` in emacs. Add
364 374 exceptions to cSpell.json.
365 375  
366 376 * If needed, run large file and image comparison tests by setting
367 377 these environment variables:
368   -
  378 +
369 379 QPDF_LARGE_FILE_TEST_PATH=/full/path
370 380 QPDF_TEST_COMPARE_IMAGES=1
371   -
  381 +
372 382 For Windows, use a Windows style path, not an MSYS path for large files.
373 383  
374 384 * If any interfaces were added or changed, check C API to see whether
... ... @@ -380,12 +390,12 @@ When done, the following should happen:
380 390  
381 391 * Double check versions and shared library details. They should
382 392 already be up to date in the code.
383   -
  393 +
384 394 * Make sure version numbers are consistent in the following locations:
385 395 * CMakeLists.txt
386 396 * include/qpdf/DLL.h
387 397 * manual/conf.py
388   -
  398 +
389 399 `make_dist` verifies this consistency, and CI fails if they are
390 400 inconsistent.
391 401  
... ... @@ -402,12 +412,12 @@ When done, the following should happen:
402 412 testing, do performance testing.
403 413  
404 414 * Test for performance and binary compatibility:
405   -
  415 +
406 416 ./abi-perf-test v<old> @
407   -
  417 +
408 418 Prefix with SKIP_PERF=1 to skip performance test.
409 419 Prefix with SKIP_TESTS=1 to skip test suite run.
410   -
  420 +
411 421 See "ABI checks" for details about the process.
412 422 End state:
413 423 * /tmp/check-abi/perf contains the performance comparison
... ... @@ -754,16 +764,16 @@ on.
754 764 that builds the concatenated string.
755 765  
756 766 * With
757   -
  767 +
758 768 ```cpp
759 769 long_function(long_function(
760 770 args)
761 771  
762 772 ```
763   -
  773 +
764 774 clang-format anchors relative to the first function, and emacs
765 775 anchors relative to the second function. Use
766   -
  776 +
767 777 ```cpp
768 778 long_function(
769 779 // line-break
... ... @@ -780,4 +790,3 @@ that clang-format produces several results. (In git this is commit
780 790  
781 791 The commits that have the bulk of automatic or mechanical reformatting are
782 792 listed in .git-blame-ignore-revs. Any new bulk updates should be added there.
783   -
... ...