[Git][NTPsec/ntpsec][master] 5 commits: Remove semi-colons from Python code
Richard Laager (@rlaager)
gitlab at mg.gitlab.com
Mon May 2 20:34:35 UTC 2022
Richard Laager pushed to branch master at NTPsec / ntpsec
Commits:
d9036b6f by James Browning at 2022-05-02T14:09:30-05:00
Remove semi-colons from Python code
This was part of !1268.
Signed-off-by: Richard Laager <rlaager at wiktel.com>
- - - - -
05568ff9 by James Browning at 2022-05-02T14:10:30-05:00
Rewrap some Python code
This was part of !1268.
Signed-off-by: Richard Laager <rlaager at wiktel.com>
- - - - -
2d63df68 by James Browning at 2022-05-02T14:10:59-05:00
Fix a typo
This was part of !1268.
Signed-off-by: Richard Laager <rlaager at wiktel.com>
- - - - -
2e058181 by Richard Laager at 2022-05-02T14:29:08-05:00
Fix inconsistent indentation
This started with changes from James Browning from !1268. I tweaked
that and fixed more issues in the same file.
Co-authored-by: James Browning <jamesb.fe80 at gmail.com>
Signed-off-by: Richard Laager <rlaager at wiktel.com>
- - - - -
a1abb59f by James Browning at 2022-05-02T15:33:50-05:00
Sort an include
This was part of !1268.
Signed-off-by: Richard Laager <rlaager at wiktel.com>
- - - - -
4 changed files:
- libntp/pymodule-mac.h
- libntp/pymodule.c
- tests/libntp/macencrypt.c
- tests/pylib/test_ntpc.py
Changes:
=====================================
libntp/pymodule-mac.h
=====================================
@@ -10,8 +10,8 @@
#ifndef GUARD_PYMODULE_MAC_H
#define GUARD_PYMODULE_MAC_H
-#include <stddef.h>
#include <stdbool.h>
+#include <stddef.h>
/* can't include Python.h or anything from openssl */
=====================================
libntp/pymodule.c
=====================================
@@ -198,11 +198,11 @@ ntpc_mac(PyObject *self, PyObject *args)
do_mac(name,
data, datalen,
- key, keylen,
- mac, &maclen);
+ key, keylen,
+ mac, &maclen);
if (maclen == 0)
- Py_RETURN_NONE;
+ Py_RETURN_NONE;
#if PY_MAJOR_VERSION >= 3
return Py_BuildValue("y#", &mac, maclen);
@@ -214,23 +214,23 @@ ntpc_mac(PyObject *self, PyObject *args)
/* List of functions defined in the module */
static PyMethodDef ntpc_methods[] = {
- {"setprogname", ntpc_setprogname, METH_VARARGS,
- PyDoc_STR("Set program name for logging purposes.")},
- {"statustoa", ntpc_statustoa, METH_VARARGS,
- PyDoc_STR("Status string display from peer status word.")},
- {"prettydate", ntpc_prettydate, METH_VARARGS,
- PyDoc_STR("Convert a time stamp to something readable.")},
- {"lfptofloat", ntpc_lfptofloat, METH_VARARGS,
- PyDoc_STR("NTP l_fp to Python-style float time.")},
- {"adj_systime", ntpc_adj_systime, METH_VARARGS,
- PyDoc_STR("Adjust system time by slewing.")},
- {"step_systime", ntpc_step_systime, METH_VARARGS,
- PyDoc_STR("Adjust system time by stepping.")},
- {"checkname", ntpc_checkname, METH_VARARGS,
- PyDoc_STR("Check if name is a valid algorithm name")},
- {"mac", ntpc_mac, METH_VARARGS,
- PyDoc_STR("Compute HMAC or CMAC from data, key, and algorithm name")},
- {NULL, NULL, 0, NULL} /* sentinel */
+ {"setprogname", ntpc_setprogname, METH_VARARGS,
+ PyDoc_STR("Set program name for logging purposes.")},
+ {"statustoa", ntpc_statustoa, METH_VARARGS,
+ PyDoc_STR("Status string display from peer status word.")},
+ {"prettydate", ntpc_prettydate, METH_VARARGS,
+ PyDoc_STR("Convert a time stamp to something readable.")},
+ {"lfptofloat", ntpc_lfptofloat, METH_VARARGS,
+ PyDoc_STR("NTP l_fp to Python-style float time.")},
+ {"adj_systime", ntpc_adj_systime, METH_VARARGS,
+ PyDoc_STR("Adjust system time by slewing.")},
+ {"step_systime", ntpc_step_systime, METH_VARARGS,
+ PyDoc_STR("Adjust system time by stepping.")},
+ {"checkname", ntpc_checkname, METH_VARARGS,
+ PyDoc_STR("Check if name is a valid algorithm name")},
+ {"mac", ntpc_mac, METH_VARARGS,
+ PyDoc_STR("Compute HMAC or CMAC from data, key, and algorithm name")},
+ {NULL, NULL, 0, NULL} /* sentinel */
};
PyDoc_STRVAR(module_doc,
@@ -249,8 +249,8 @@ NTPSEC_PY_MODULE_INIT(ntpc)
/* Create the module and add the functions */
NTPSEC_PY_MODULE_DEF(m, "ntpc", module_doc, ntpc_methods)
- /* for statustoa() */
- PyModule_AddIntConstant(m, "TYPE_SYS", TYPE_SYS);
+ /* for statustoa() */
+ PyModule_AddIntConstant(m, "TYPE_SYS", TYPE_SYS);
PyModule_AddIntConstant(m, "TYPE_PEER", TYPE_PEER);
PyModule_AddIntConstant(m, "TYPE_CLOCK", TYPE_CLOCK);
=====================================
tests/libntp/macencrypt.c
=====================================
@@ -25,7 +25,7 @@ const int packetLength = 16;
const int keyIdLength = 4;
const int digestLength = 16;
-/* Need #define to avoie VLA (variable length array) */
+/* Need #define to avoid VLA (variable length array) */
#define totalLength 36
char expectedMD5Packet[] = "ijklmnopqrstuvwx\0\0\0\0\x0c\x0e\x84\xcf\x0b\xb7\xa8\x68\x8e\x52\x38\xdb\xbc\x1c\x39\x53";
=====================================
tests/pylib/test_ntpc.py
=====================================
@@ -13,17 +13,20 @@ class TestPylibNtpc(unittest.TestCase):
]
def test_statustoa(self):
- self.assertEqual("leap_add_sec, sync_22, 7 events, no_sys_peer",
- ntp.ntpc.statustoa(ntp.ntpc.TYPE_SYS, 0x12345678));
- self.assertEqual("authenb, reach, sel_sys.peer, 7 events, access_denied",
- ntp.ntpc.statustoa(ntp.ntpc.TYPE_PEER, 0x12345678));
- self.assertEqual("7 events, clk_8",
- ntp.ntpc.statustoa(ntp.ntpc.TYPE_CLOCK, 0x12345678));
+ self.assertEqual(
+ "leap_add_sec, sync_22, 7 events, no_sys_peer",
+ ntp.ntpc.statustoa(ntp.ntpc.TYPE_SYS, 0x12345678))
+ self.assertEqual(
+ "authenb, reach, sel_sys.peer, 7 events, access_denied",
+ ntp.ntpc.statustoa(ntp.ntpc.TYPE_PEER, 0x12345678))
+ self.assertEqual(
+ "7 events, clk_8",
+ ntp.ntpc.statustoa(ntp.ntpc.TYPE_CLOCK, 0x12345678))
def test_lfp(self):
for (in_string, to_float, to_string) in self.lfp_set:
- self.assertEqual(ntp.ntpc.prettydate(in_string), to_string);
- self.assertAlmostEqual(ntp.ntpc.lfptofloat(in_string), to_float);
+ self.assertEqual(ntp.ntpc.prettydate(in_string), to_string)
+ self.assertAlmostEqual(ntp.ntpc.lfptofloat(in_string), to_float)
if __name__ == '__main__':
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/a7ab3cba7abebedfec35a0b95dc60c88b7135755...a1abb59fc61ce9a8db52bdf9b45f8d7813161f02
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/a7ab3cba7abebedfec35a0b95dc60c88b7135755...a1abb59fc61ce9a8db52bdf9b45f8d7813161f02
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20220502/b4f70594/attachment-0001.htm>
More information about the vc
mailing list