Commit Graph

38 Commits

Author SHA1 Message Date
João Valverde e0dba4854b Exclude wmem_test.c from pre-commit 2021-12-18 20:13:41 +00:00
Guy Harris d4ed129727 pre-commit: skip some checks on idl2wrs.c.
Some checks intended for dissectors don't work well on dissector
*generators*, as they see stuff such as "value_string %s[]" in a format
string used to generate dissector code and get upset because the
purported value_string doesn't end with {0, NULL} (the generator *does*
put a {0, NULL} at the end, but the checker isn't clever enough to
figure that out).
2021-09-11 02:42:51 -07:00
Moshe Kaplan e16166a74c Detect and replace bad allocation patterns
Adds a pre-commit hook for detecting and replacing
occurrences of `g_malloc()` and `wmem_alloc()` with
`g_new()` and `wmem_new()`, to improve the
readability of Wireshark's code, and
occurrences of
`g_malloc(sizeof(struct myobj) * foo)`
with
`g_new(struct myobj, foo)`
to prevent integer overflows

Also fixes all existing occurrences across
the codebase.
2020-12-22 14:56:38 +00:00
Gerald Combs 50550708cc Add merge request jobs to GitLab CI and migrate commit validation.
Copy the Buildbot petri dish builder steps to corresponding GitLab CI
jobs. Update validate-commit.py to look for old "Bug:" and "Ping-Bug:"
references and have it call `git stripspace` directly. tools/commit-msg
was specific to Gerrit, so remove it.

Change-Id: Icbc54709052f44c941db9ad6a5dcf596292782a2
2020-08-23 17:46:18 -07:00
Gerald Combs bfb7028ba9 More shellcheck fixes.
Change-Id: Iee9e464b3935d4c8a09fa9954f73496eae33f30f
Reviewed-on: https://code.wireshark.org/review/28092
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-06-11 16:35:08 +00:00
Gerald Combs 8bf24f51cb Pre-commit: Don't force whitespace checks everywhere.
Move the whitespace check (git diff-index --check --cached) inside the
CHECK_FILES loop, otherwise editing SVGs with Inkscape will be much less
convenient.

Change-Id: I2b9e3575d54091572caa89e3e317e5e121984010
Reviewed-on: https://code.wireshark.org/review/25144
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2018-01-04 21:32:27 +00:00
Matthieu Coudron 13adab2118 Update message on outdated precommit hook
Change-Id: I3afb93cced09df7844c0810438ee6d760f8237a5
Reviewed-on: https://code.wireshark.org/review/18960
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-11-28 16:00:03 +00:00
Alexis La Goutte 85c1a45c38 pre-commit: fix indent
Change-Id: I50291be3fd275cde8af42c45c17e52345d1c6215
Reviewed-on: https://code.wireshark.org/review/18619
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-11-02 12:18:46 +00:00
Jeff Morriss 8a376d4cd3 Validate the Diameter XML files in the pre-commit script.
Validation requires xmllint but will pass (with a complaint) if the committer
does not have xmllint installed.

Change-Id: I336a1c8ad8e1f98805a284d8c4736810b1a9c54e
Reviewed-on: https://code.wireshark.org/review/18609
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-11-02 04:42:47 +00:00
Joerg Mayer cd426f3fe2 Add a comment how to run git review after using --no-verfiy.
Change-Id: I07cde41ef6f8074efbb77eacde91b46b62c2f59e
Reviewed-on: https://code.wireshark.org/review/18230
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-10-17 05:41:46 +00:00
João Valverde 0a609d4195 pre-commit: Ignore missing pre-commit-ignore.py
Print error message to stderr and return non-zero exit status from
child process.

Change-Id: Icd433d79c5a7bf8b6ddd8e94e26695b353e34d1f
Reviewed-on: https://code.wireshark.org/review/17116
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: João Valverde <j@v6e.pt>
2016-08-18 11:00:27 +00:00
João Valverde 9cbcdee753 pre-commit: Make version check work with git-worktree
By disabling it outside the main working tree this time.

Change-Id: I2075b07370e3cc1395c6de9695e40b0a952e3eab
Reviewed-on: https://code.wireshark.org/review/17122
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: João Valverde <j@v6e.pt>
2016-08-17 23:50:24 +00:00
João Valverde 3119e2fc23 pre-commit: Fix version check to work with git-worktree
Change-Id: Ie895ca194738a022cc211ae50afbff0a561156a3
Reviewed-on: https://code.wireshark.org/review/17047
Reviewed-by: João Valverde <j@v6e.pt>
2016-08-15 10:02:30 +00:00
Guy Harris 172b74d734 Portably remove CRs from Python output.
The GNU sed manual says the only C-style backslash escapes that can be
used in regular expressions in portable sed scripts are \n and \\.

The Single UNIX Specification says that \r is one of the C-style
backslash escapes that can be used in tr, so use tr -d instead.

Change-Id: I40d97ee9b89dfce3d67f062ec8839d3aba998ff3
Reviewed-on: https://code.wireshark.org/review/14606
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-24 01:09:03 +00:00
Guy Harris 77b26d6d71 That's not specific to OS X.
OS X's sed appears to be a *BSD sed, so the same problem might exist on
*BSD, or at least some *BSDs, and it might, in fact, be a problem with
everything except for GNU sed.

Change-Id: I267d9d7eb077c8ec39135bac7eff2c765af3efcf
Reviewed-on: https://code.wireshark.org/review/14601
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-23 20:12:41 +00:00
Joerg Mayer e8472e5660 Fix a problem that prevented checkins of all filenames containing the
character 'r' on MacOS with an active pre-commit hook.

Change-Id: If26fb22d5057794ec0de0def4055310b78a05f89
Reviewed-on: https://code.wireshark.org/review/14600
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-03-23 19:58:51 +00:00
João Valverde c51d859551 pre-commit: Use uname -a instead.
Not all shells support uname -o.

Change-Id: Ia6f46f3580f6d7b421da672418dcbee38ad9e60b
Reviewed-on: https://code.wireshark.org/review/14143
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-25 14:17:43 +00:00
João Valverde fe1de0146e pre-commit: Avoid launching python subprocesses.
This makes Python required only for (portable) fnmatch().

Change the ignore script to work as a filter.

Multi-platform improvements.

Change-Id: I6ac757d48ba2ff965da5da3dc9c25047a0e37f92
Reviewed-on: https://code.wireshark.org/review/13693
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-25 12:34:50 +00:00
João Valverde 0a931aa383 Add fnmatch support to git pre-commit hook
Allows for wildcard pathname matching in ignore list.

Change-Id: I52e47c72c69e16ff9aefadfde22d1bd682df9654
Reviewed-on: https://code.wireshark.org/review/13166
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2016-01-28 10:38:29 +00:00
João Valverde 5815d1080a Add basic exclude facility to pre-commit hook checks
Change-Id: If08fd1481e58f785fed90a7d8c24aa2a1e0f3df7
Reviewed-on: https://code.wireshark.org/review/12958
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-05 21:32:22 +00:00
Peter Wu 28128ca41c tools/pre-commit: compare files instead of mtime
Instead of unconditionally checking for the file mtime, compare file
contents instead. Perform this check only for invocations via a hook.

While at it, simplify setting defaults for the git directory and the
commit identifier. Support executions via relative paths and update the
help messages on top of the file.

Change-Id: I89c015fe6553ad52e07795683dd88cb219a26ed2
Reviewed-on: https://code.wireshark.org/review/8923
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-09-08 11:01:18 +00:00
Michal Labedzki b99cf21c25 extcap: Add support for Android - androiddump
androiddump is extcap program that can be used with Android devices
(need Android SDK in system PATH). Supported is Logcat/Logger logs and
Bluetooth interfaces for all Android to this day (Lollipop).

Please note that it will work also for FirefoxOS.

Interfaces:
1. Logcat Main (binary or text)
2. Logcat System (binary or text)
3. Logcat Events (binary or text)
4. Logcat Radio (binary or text)
5. Logcat Crash (text; Lollipop)
6. Bluetooth Hcidump (<Kitkat)
7. Bluetooth Bluedroid External Parser (Kitkat)
8. Bluetooth BtsnoopNet (Lollipop)

Change-Id: I26e4cd1a37a6af805f8b932399b4aa44ee7b5a80
Reviewed-on: https://code.wireshark.org/review/7475
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Michal Labedzki <michal.labedzki@tieto.com>
2015-04-08 09:57:24 +00:00
Alexis La Goutte 7f22ce7f66 pre-commit tools: Add arg option to specify the commit id to be checked
If no commit id specify, it is HEAD

Thanks to Michal for the help :-)

Change-Id: Ibf579aed47c7574f9a01d868ae0d55bbe789a8a2
Reviewed-on: https://code.wireshark.org/review/5474
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-11-25 13:21:41 +00:00
Michael Mann 570df7592d Add checkfiltername.pl to pre-commit script
Change-Id: I34d8aa7034a4aacc2a95b35a30f25356b33a51b9
Reviewed-on: https://code.wireshark.org/review/5187
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-11-08 07:23:42 +00:00
Evan Huus f25f1ea562 Don't try and run checkAPIs.pl on deleted files
It fails, for obvious reasons, and makes it impossible to commit the removal of
c/h files.

Change-Id: Ifcd067f8959684e2e0191983fd60fb94ae86bca3
Reviewed-on: https://code.wireshark.org/review/3401
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-08-04 11:50:08 +00:00
Bill Meier b66f614e5d pre-commit: Add 'unset GREP_OPTIONS' (similar to Gerrit commit-msg)
msysgit grep is fairly old and doesn't recognize certain
  grep options, e.g., '--color=auto'.

  I imagine there may possibly be other grep option issues
  on various platforms.

  (I also note that the various git scripts in libexec/git-core
   clear out GREP_OPTIONS before calling grep).

Change-Id: I67bc148a77cfc0167064e61e8c47a5f091704eac
Reviewed-on: https://code.wireshark.org/review/2945
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-07-08 20:00:52 +00:00
Bill Meier cdf6d62b3b tools/pre-commit: Complete all checks on all files before exiting with Ok/Fail status.
Change-Id: Iea6df6fbe5a977b282e823f87cd9f760e92a3e22
Reviewed-on: https://code.wireshark.org/review/2918
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-07-08 00:49:47 +00:00
Anish Bhatt 8878d7778e Current test for GIT_DIR introduced in changeset Ie1560c372e23e58fb0e310f681388b5e1a65ba5b doesn't seem to be working correctly on bash 4.3.18 : .git/hooks/pre-commit: line 11: .git: command not found
This test works correctly in bash/dash/zsh

Change-Id: Ic89fc2764d1a70e9e5d112c7928cee6ed783f50f
Signed-off-by: Anish Bhatt <anish@chelsio.com>
Reviewed-on: https://code.wireshark.org/review/2092
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-06-10 00:58:20 +00:00
Joerg Mayer 03f75ddfee It is possible to check out a source tree that is not co-located with
the .git repository. First attempts to support that setup.

Change-Id: Ie1560c372e23e58fb0e310f681388b5e1a65ba5b
Reviewed-on: https://code.wireshark.org/review/1596
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2014-05-11 19:35:33 +00:00
Hadriel Kaplan 0a5572ea77 Fix Bug 9951: 'git commit hook isn't calling checkAPIs.pl with arguments for the dissectors'
I recently made a change to packet-rtp.c and inappropriately included
g_error() in it, which the builbots caught during their run of checkAPIs.pl.
But checkAPIs.pl is supposed to catch such things for us before we submit, by
being invoked in the git pre-commit hook.

Apparently though, buildbots call checkAPIs.pl with extra arguments for
different cases... and for packet dissectors it calls it with a '-g abort'
argument, which is how it caught the g_error.

So the "bug" is that the pre-commit hook should invoke checAPIs.pl with that
argument too, for epan/dissectors/packet-*.c files.

Change-Id: Ie8f9dcc55f2248918208dea85a04f67e6bf9829a
Reviewed-on: https://code.wireshark.org/review/953
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-14 00:10:20 +00:00
Evan Huus 16e7096df3 Remove duplicate call to fix-encoding-args
Change-Id: I7067a8856ff1c431d5e5ec7ec2a51228a8613631
Reviewed-on: https://code.wireshark.org/review/743
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-19 17:10:17 +00:00
Alexis La Goutte 9f01daa2dc Add check of whitespace error after Wireshark check (checkhf, checAPIs...)
(Because check whitespace quit after check... and no longer launch other check...)

Change-Id: I97ee0191c3d985934e74d23576f88984ec0e9b46
Reviewed-on: https://code.wireshark.org/review/739
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-19 13:03:39 +00:00
Alexis La Goutte 1db0fc5c98 Enhance pre-commit tools to avoid false positive
Limit check to file with extension *.c or *.h

Patch revert by mistake in 49394d3101

Change-Id: Ifed4c833c740218e5e24b3176dc20802fa5849bb
Reviewed-on: https://code.wireshark.org/review/719
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-03-17 17:22:23 +00:00
Roland Knall 73618c8d1c Pre-Commit Hook check to check for newer version
Insert a short check to always check for newer versions
 in the tool directory of the pre-commit script

 So far, only a warning is being generated, allowing the
 developer to decide for him/herself

Change-Id: I6fce60e3de1d051757d0ed38eae8fdc94cec7662
Reviewed-on: https://code.wireshark.org/review/633
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-13 14:46:36 +00:00
Alexis La Goutte 49394d3101 Update Wireshark pre-commit tools (Add check for trailing whitespace based from git pre-commit.sample)
Change-Id: If8f5f48dfd96c3657036f7b59b6ca905c9d24043
Reviewed-on: https://code.wireshark.org/review/531
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-06 17:05:57 +00:00
Alexis La Goutte 2e1f11289b Enhance pre-commit tools to avoid false positive
Limit check to file with extension *.c or *.h

Change-Id: I6e237e6fd053083d271924120973a6b07e2d4e53
Reviewed-on: https://code.wireshark.org/review/247
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-20 18:24:05 +00:00
Jeff Morriss 82e2865739 Remove $Id$ and other Subversion leftovers from the tools.
There are a few things in here which could still use attention.

Don't regenerate anything now.

Change-Id: I283c224d3523212144707fca3d6265916cb11792
Reviewed-on: https://code.wireshark.org/review/205
Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2014-02-14 01:35:57 +00:00
Alexis La Goutte 45b9f5964b Add my pre-commit git script (with checkAPI/hf/encoding args...) Need to copy in .git/hooks folder and will be launch all check when make local commit (if there is some false-positive add --no-verify to disable check)
Should be enhance to be better (check trailing/whitespace...)

svn path=/trunk/; revision=51884
2013-09-09 19:30:39 +00:00