]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: Avoid random numbers in dm_test_devm_regmap()
authorSimon Glass <sjg@chromium.org>
Fri, 14 May 2021 01:39:23 +0000 (19:39 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 24 May 2021 18:21:30 +0000 (14:21 -0400)
There is no good reason to use a sequence from rand() here. We may as well
invent our own sequence.

This should molify Coverity which does not use rand() being used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 312949)
test/dm/regmap.c

index 372a73ca0c37d0b51abe8372e132e2e4a142b18e..04bb1645d1ba19adbda068ebaaa4f5972012c902 100644 (file)
@@ -306,9 +306,8 @@ static int dm_test_devm_regmap(struct unit_test_state *uts)
                                              &dev));
        priv = dev_get_priv(dev);
 
-       srand(get_ticks() + rand());
        for (i = 0; i < REGMAP_TEST_BUF_SZ; i++) {
-               pattern[i] = rand();
+               pattern[i] = i * 0x87654321;
                ut_assertok(regmap_write(priv->cfg_regmap, i, pattern[i]));
        }
        for (i = 0; i < REGMAP_TEST_BUF_SZ; i++) {