~ubuntu-branches/debian/stretch/device-tree-compiler/stretch

« back to all changes in this revision

Viewing changes to tests/supernode_atdepth_offset.c

  • Committer: Package Import Robot
  • Author(s): Hector Oron
  • Date: 2011-11-22 12:23:38 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20111122122338-ljbxy6a31fqztakc
Tags: 1.3.0-1
* New upstream release. (Closes: #572945)
* New maintainer. (Closes: #649290)
* New VCS repository.
* Update homepage stanza (Closes: #497605)
* Update standards version.
* Compile with -fPIC. Fixes ftbfs on amd64.
* Use dpkg 1.0 format.
* Backport upstream fixes as patches until 2011-10-26.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * License along with this library; if not, write to the Free Software
18
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
19
 */
20
 
#define _GNU_SOURCE
21
 
 
22
20
#include <stdlib.h>
23
21
#include <stdio.h>
24
22
#include <string.h>
30
28
#include "tests.h"
31
29
#include "testdata.h"
32
30
 
33
 
int path_depth(const char *path)
 
31
static int path_depth(const char *path)
34
32
{
35
33
        const char *p;
36
34
        int depth = 0;
51
49
                return depth;
52
50
}
53
51
 
54
 
int path_prefix(const char *path, int depth)
 
52
static int path_prefix(const char *path, int depth)
55
53
{
56
54
        const char *p;
57
55
        int i;
64
62
 
65
63
        p = path;
66
64
        for (i = 0; i < depth; i++)
67
 
                p = strchrnul(p+1, '/');
 
65
                p = p+1 + strcspn(p+1, "/");
68
66
 
69
67
        return p - path;
70
68
}
71
69
 
72
 
void check_supernode_atdepth(struct fdt_header *fdt, const char *path,
 
70
static void check_supernode_atdepth(struct fdt_header *fdt, const char *path,
73
71
                             int depth)
74
72
{
75
73
        int pdepth = path_depth(path);
76
74
        char *superpath;
77
 
        int nodeoffset, supernodeoffset, superpathoffset;
 
75
        int nodeoffset, supernodeoffset, superpathoffset, pathprefixlen;
78
76
        int nodedepth;
79
77
 
80
 
        superpath = strndupa(path, path_prefix(path, depth));
 
78
        pathprefixlen = path_prefix(path, depth);
 
79
        superpath = alloca(pathprefixlen + 1);
 
80
        strncpy(superpath, path, pathprefixlen);
 
81
        superpath[pathprefixlen] = '\0';
 
82
 
81
83
        verbose_printf("Path %s (%d), depth %d, supernode is %s\n",
82
84
                       path, pdepth, depth, superpath);
83
85
 
104
106
                     "instead of %d", nodedepth, pdepth);
105
107
}
106
108
 
107
 
void check_supernode_overdepth(struct fdt_header *fdt, const char *path)
 
109
static void check_supernode_overdepth(struct fdt_header *fdt, const char *path)
108
110
{
109
111
        int pdepth = path_depth(path);
110
112
        int nodeoffset, err;
119
121
                     "of FDT_ERR_NOTFOUND", path, pdepth+1, err);
120
122
}
121
123
 
122
 
void check_path(struct fdt_header *fdt, const char *path)
 
124
static void check_path(struct fdt_header *fdt, const char *path)
123
125
{
124
126
        int i;
125
127