Skip to content

Conversation

@FrazerClews
Copy link

WIP since the last commit needs a double check for if it's correct for memset

@keszybz keszybz added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label May 6, 2020
@keszybz keszybz added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels May 6, 2020
@keszybz
Copy link
Member

keszybz commented May 6, 2020

../src/journal/lookup3.c:795:30: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘time_t’ {aka ‘long int’} [-Werror=format=]
  795 |   if (z-a > 0) printf("time %d %.8x\n", z-a, h);
      |                             ~^          ~~~
      |                              |           |
      |                              int         time_t {aka long int}
      |                             %ld

So this format string is stil wrong.

@keszybz
Copy link
Member

keszybz commented May 6, 2020

Please add this commit to your PR after it all compiles:

0001-tests-turn-lookup3-into-a-test.patch.txt

t = dns_type_to_string(key->type);

snprintf(buf, buf_size, "%s %s%s%.0u %s%s%.0u",
snprintf(buf, buf_size, "%s %s%s%.0d %s%s%.0d",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRIu16

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc -Isrc/resolve/085a0f9@@systemd-resolve-core@sta -Isrc/resolve -I../src/resolve -Isrc/basic -I../src/basic -Isrc/boot -I../src/boot -Isrc/home -I../src/home -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -Isrc/core -I../src/core -Isrc/shutdown -I../src/shutdown -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Werror=shadow -include config.h -fPIC -MD -MQ 'src/resolve/085a0f9@@systemd-resolve-core@sta/resolved-dns-rr.c.o' -MF 'src/resolve/085a0f9@@systemd-resolve-core@sta/resolved-dns-rr.c.o.d' -o 'src/resolve/085a0f9@@systemd-resolve-core@sta/resolved-dns-rr.c.o' -c ../src/resolve/resolved-dns-rr.c
../src/resolve/resolved-dns-rr.c: In function ‘dns_resource_key_to_string’:
../src/resolve/resolved-dns-rr.c:324:44: error: unknown conversion type character ‘P’ in format [-Werror=format=]
  324 |         snprintf(buf, buf_size, "%s %s%s%.0PRIu16 %s%s%.0PRIu16",
      |                                            ^
../src/resolve/resolved-dns-rr.c:324:52: error: format ‘%s’ expects argument of type ‘char *’, but argument 7 has type ‘int’ [-Werror=format=]
  324 |         snprintf(buf, buf_size, "%s %s%s%.0PRIu16 %s%s%.0PRIu16",
      |                                                   ~^
      |                                                    |
      |                                                    char *
      |                                                   %d
  325 |                  dns_resource_key_name(key),
  326 |                  strempty(c), c ? "" : "CLASS", c ? 0 : key->class,
      |                                                 ~~~~~~~~~~~~~~~~~~
      |                                                       |
      |                                                       int
../src/resolve/resolved-dns-rr.c:324:58: error: unknown conversion type character ‘P’ in format [-Werror=format=]
  324 |         snprintf(buf, buf_size, "%s %s%s%.0PRIu16 %s%s%.0PRIu16",
      |                                                          ^
../src/resolve/resolved-dns-rr.c:324:33: error: too many arguments for format [-Werror=format-extra-args]
  324 |         snprintf(buf, buf_size, "%s %s%s%.0PRIu16 %s%s%.0PRIu16",
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~```

Copy link
Member

@mrc0mmand mrc0mmand May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRIu16 is a format string, so it should be used as:

snprintf(buf, buf_size, "%s %s%s%" PRIu16 " %s%s%" PRIu16,
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, fixed locally, just trying to get #15729 (comment) patched but having some issues

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, not actually fixed, is it?

@poettering
Copy link
Member

i am not sure it's worth fixing a source code we copied in, and probably should stay close to its origin like this, in particular if the code is ifdeffed out...

But if we fix that, then at least do it properly, using the PRI macros

Copy link
Member

@keszybz keszybz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure it's worth fixing a source code we copied in, and probably should stay close to its origin like this, in particular if the code is ifdeffed out...

I think it is. See my comment above, we can than run it as a unit test.

@FrazerClews
Copy link
Author

FrazerClews commented May 11, 2020

Please add this commit to your PR after it all compiles:

0001-tests-turn-lookup3-into-a-test.patch.txt

@keszybz Are you OK that I applied it manually, couldn't do git am and needed some extra work to fix the errors and warnings? I can reference you in the commit? Will fixup the commit after

@keszybz
Copy link
Member

keszybz commented May 11, 2020

Looks OK, but please remove the "wip" strings... We don't want that in git log.

@FrazerClews
Copy link
Author

Looks OK, but please remove the "wip" strings... We don't want that in git log.

Agreed, but it still doesn't pass. Even after fixing the errors in the test script caught by pylint. Will investigate why but not entirely sure why, my guess is that it needs re-factoring but could be wrong

{
h = hashlittle(buf, 0, h);
printf("%2ld 0-byte strings, hash is %.8x\n", i, h);
printf("%2u 0-byte strings, hash is %.8x\n", i, h);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

t = dns_type_to_string(key->type);

snprintf(buf, buf_size, "%s %s%s%.0u %s%s%.0u",
snprintf(buf, buf_size, "%s %s%s%" PRIu16 " %s%s%" PRIu16,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't drop the .0

@keszybz
Copy link
Member

keszybz commented May 19, 2020

@FrazerClews can we please have another round here?

@FrazerClews
Copy link
Author

FrazerClews commented May 19, 2020

@keszybz sorry, been very busy and have had to put this off for a bit, and trying to get the test working. Do you want the logs of the test?

@FrazerClews FrazerClews reopened this May 19, 2020
@FrazerClews FrazerClews force-pushed the frazer/invalidArg branch 2 times, most recently from bb9c2be to acafc85 Compare May 27, 2020 23:19
@FrazerClews FrazerClews force-pushed the frazer/invalidArg branch 3 times, most recently from ca6f61c to 58c40d1 Compare June 8, 2020 14:14
@FrazerClews FrazerClews force-pushed the frazer/invalidArg branch 3 times, most recently from 2ea82ad to 2deb6e6 Compare June 9, 2020 16:38
Copy link

@hixiomh hixiomh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull requested

@FrazerClews FrazerClews force-pushed the frazer/invalidArg branch 2 times, most recently from 7d910ff to 91a189c Compare June 11, 2020 01:28
}
time(&z);
if (z-a > 0) printf("time %d %.8x\n", z-a, h);
if (z-a > 0) printf("time %ld %.8x\n", z-a, h);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, if we wanted to do this fully correctly, we'd define TIME_FMT that maps to the correct format string for time_t... We do it like that for uid_t → UID_FMT, pid_t → PID_FMT and so on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the function difftime() and used lf as the string format for doubles to have it as close as it was before. If that's what you want it?

t = dns_type_to_string(key->type);

snprintf(buf, buf_size, "%s %s%s%.0u %s%s%.0u",
snprintf(buf, buf_size, "%s %s%s%.0d %s%s%.0d",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, not actually fixed, is it?

@FrazerClews FrazerClews force-pushed the frazer/invalidArg branch 4 times, most recently from 8aea240 to 55b2f27 Compare June 13, 2020 02:03
Frazer Clews added 3 commits June 19, 2020 12:57
- also remove unused variables and fix string format
- systemd-networkd-tests.py singleton comparison and simplify inheritance
- remove resolvectl test while -t MX still fails when DNSSEC is enabled
@FrazerClews FrazerClews changed the title WIP: remove invalid string format and args remove invalid string format and args Jun 19, 2020
Copy link

@dnicolodi dnicolodi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first patch seems ok. The second one has a couple of good hunks in it, but the hash lookup tests and the changes to the networkd test suite should be split into two separate patches. I think that the third patch should go. Other comments inline.

not (expected == 'managed' and actual != 'unmanaged')):
self.fail("Link {} expects state {}, found {}".format(iface, expected, actual))
err_msg = "Link {} expects state {}, found {}".format(iface, expected, actual)
self.fail(err_msg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a hack to get it working during testing, before if you got an error, it would print Link {} expects state {}, found {} and not format. Trying to find a better solution



class BridgeTest(NetworkdTestingUtilities, unittest.TestCase):
class BridgeTest(unittest.TestCase, NetworkdTestingUtilities):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make a difference in practice?

def setUpClass(klass):
klass.orig_log_level = subprocess.check_output(
def setUpClass(cls):
cls.orig_log_level = subprocess.check_output(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cls may be a tiny bit more idiomatic than klass, but I don't see the point of this change and similar ones below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to follow python convention of having the class argument being called cls. Which makes it easier for new users and tools like pylint to know what it does

out = subprocess.check_output(['resolvectl', 'query', '--type=MX', 'example.com'])
self.assertIn(b'example.com IN MX 1 mail.example.com', out)
# out = subprocess.check_output(['resolvectl', 'query', '--type=MX', 'example.com'])
# self.assertIn(b'example.com IN MX 1 mail.example.com', out)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is ok to comment out tests...

Copy link
Author

@FrazerClews FrazerClews Jun 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed and I think is due to the issue listed above
# FIXME: -t MX query fails with enabled DNSSEC (even when using
# the known negative trust anchor .internal instead of .example.com)



class Utilities():
class Utilities(unittest.TestCase):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

self.assertRegex(output, address_regex)

class NetworkctlTests(unittest.TestCase, Utilities):
class NetworkctlTests(Utilities):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the point. The code was actually more semantically correct before. It of course applies to all similar changes below.

#define hashlittle2 jenkins_hashlittle2
#define hashword jenkins_hashword
#define hashword2 jenkins_hashword2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this is necessary.

Copy link
Author

@FrazerClews FrazerClews Jun 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this commit to your PR after it all compiles:

0001-tests-turn-lookup3-into-a-test.patch.txt

This was a patch @keszybz wanted

Base automatically changed from master to main January 21, 2021 11:54
@poettering
Copy link
Member

Let's close this. After a4ea5d1 I think we get most types right, and the compiler should warn us where we don't.

if you see this is not the case, please file a new PR.

@poettering poettering closed this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks tree-wide

Development

Successfully merging this pull request may close these issues.

7 participants